<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<jsp:include page="./header.jsp" />

<%@page import="java.util.*"%>
<%@page import="domain.*"%>
<%@page import="util.*"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<%
	Schedule schedule = (Schedule) request.getAttribute("schedule");
%>
<title>Get Schedule</title>

	<script type="text/javascript">
	  
		function showMap(url){
			document.forms[0].method = "get";
			document.forms[0].action = "./"+url;
			document.forms[0].submit();
		}
			
	</script>
</head>
<body>
	<div data-role="page" data-theme="a" id="mainPage">

	<div data-role="header" >
		<h1>Get Schedule</h1>
	</div><!-- /header -->

	<div data-role="content" >
		
		
			<% 
				if(schedule!=null){
			%>
				<div align="right"><%=schedule.getRoute()%> - <%= DateUtil.getDDMMYYYYFromDate(schedule.getStartTime(), 0) %></div>
				<ul data-role="listview" data-inset="true" data-theme="a">
			<% 
				List<Mission> missions = schedule.getMissions();
					for(int i=0; i<missions.size(); i++){
						Mission mission = missions.get(i);
			%>
				<li><a href="#detail<%= mission.getPriority()%>" data-transition="pop" data-rel="dialog"><%=mission.getPriority()%>. <%=mission.getToPOS().getName() %></a></li>
			<% }%>
				</ul>
			<%} %>
		
		<br/>
		<form id="showMap"></form>
		<div data-role="button" onclick="showMap('GetTraffic')">Show On Map</div>
		
	</div><!-- /content -->

	<div data-role="footer" class="ui-bar">
			<h4></h4>
	</div><!-- /footer -->
	</div><!-- /page -->
	
	<!-- Orther dialogs -->
	<% 	if(schedule!=null){
			List<Mission> missions = schedule.getMissions();
			for(int i=0; i<missions.size(); i++){
				Mission mission = missions.get(i);
	%>
		<div data-role="page" id="detail<%=mission.getPriority() %>" data-theme="a">
	
		<div data-role="header">
			<h1><%=mission.getToPOS().getName() %></h1>
		</div><!-- /header -->
	
		<div data-role="content">
			<ul data-role="listview" >
				<li>From: <%=mission.getFromPOS().getName() %></li>
				<li>To: <%=mission.getToPOS().getName() %></li>
				<li>Brand: <%=mission.getBrandName()!=null && mission.getBrandName()!=""? mission.getBrandName():"-" %></li>
				<li>No. Of Product: <%=mission.getNoOfProduct()!=0? mission.getNoOfProduct():"-" %></li>
				<li>Priority: <%=mission.getPriority()%></li>
				<li>Type: <%=mission.getDevType() %></li>
			</ul>		
		</div><!-- /content -->
	
		<div data-role="footer">
			<h4></h4>
		</div><!-- /footer -->
		</div><!-- /page -->
	</div>
	<% }}%>
</body>
</html>